CREATE TABLE [dbo].[C_GROUPS]
(
[cup] [numeric] (4, 0) NOT NULL,
[team] [varchar] (25) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[groupId] [varchar] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[rank] [numeric] (1, 0) NOT NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[C_GROUPS] ADD CONSTRAINT [ch_C_Groups_group] CHECK (([groupId]>='A' AND [groupId]<='H'))
GO
ALTER TABLE [dbo].[C_GROUPS] ADD CONSTRAINT [ch_C_Groups_rank] CHECK (([rank]>(0) AND [rank]<=(4)))
GO
ALTER TABLE [dbo].[C_GROUPS] ADD CONSTRAINT [pk_C_Groups] PRIMARY KEY CLUSTERED  ([cup], [groupId], [rank]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[C_GROUPS] ADD CONSTRAINT [uk_C_Groups_team] UNIQUE NONCLUSTERED  ([cup], [team]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[C_GROUPS] ADD CONSTRAINT [fk_C_Groups_cup] FOREIGN KEY ([cup]) REFERENCES [dbo].[C_CUPS] ([cup])
GO
ALTER TABLE [dbo].[C_GROUPS] ADD CONSTRAINT [fk_C_Groups_team] FOREIGN KEY ([team]) REFERENCES [dbo].[C_TEAMS] ([team])
GO
